using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using NovodexWrapper;

/// <summary>
/// object to click on, spits out a set of marbles
/// orignially a treasure chest is now a pyramid
/// </summary>
/// 
namespace marbletrack
{
    public class TreasureChest:Obstacle
    {
        //private int frameCount = 0;

        public TreasureChest(Vector3 modelPosition)
        {
            SetupVariables(Vector3.Zero, modelPosition);
        }

        internal override void SetupVariables(Vector3 rotation, Vector3 modelPosition)
        {
            modelScale_ = 1f;
            active = false;
            mouseClickTolerance = Game1.SQUARESIZE*5;
            nextModelPosition_ = modelPosition_ = modelPosition;
            // Setup orientation variables
            modelRotation_ = rotation;
            // Load model
            model_ = Game1.EndPiece;
            CorrectPosition_ = Matrix.CreateTranslation(new Vector3(0, 0, 0));
            transformMatrix_ = ApplyTransformations();
            physics.CreateTriangleMeshActor(model_.MeshVertexBuffers[0], model_.MeshIndexBuffers[0], transformMatrix_, Physics.TRACKPIECE_PHYSICS_GROUP, true, model_.FlipNormalsFlag);
        }

        public override void Update()
        {
            if (active)
            {
                Game1.CreateParticles(modelPosition_ + Vector3.UnitY * Game1.SQUARESIZE, new Vector3(1, -1, 1));
                active = false;
            }
        }

        public override void Draw()
        {
            transformMatrix_ = ApplyTransformations();
            model_.Draw(transformMatrix_);
        }
    }
}